package com.frxuexi.mynews.fragment

import android.os.Bundle
import android.util.Log
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import com.frxuexi.mynews.R
import com.tencent.mmkv.MMKV

// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private const val ARG_PARAM1 = "param1"
private const val ARG_PARAM2 = "param2"

/**
 * A simple [Fragment] subclass.
 * Use the [VideoFragment.newInstance] factory method to
 * create an instance of this fragment.
 */
class VideoFragment : Fragment() {

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val mmkv = MMKV.defaultMMKV()
        mmkv.encode("name","张三")

        // Inflate the layout for this fragment
        val view = inflater.inflate(R.layout.fragment_video, container, false)
        view.findViewById<Button>(R.id.btn_get)
            .setOnClickListener {
                Log.i("===",mmkv.decodeString("name","aa")!!)
            }

        view.findViewById<Button>(R.id.btn_remove)
            .setOnClickListener {
//                mmkv.removeValueForKey("name")
                mmkv.remove("name")

            }
        return view
    }
}